package com.chang.resourceLoader;

import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.core.io.Resource;

public class ResourceLoaderDemo {

    /* new的哪个对象, getResource时返回的就是哪种类型,
    如果ApplicationContext是FileSystemXmlApplicationContext，res就是FileSystemResource实例；
    如果ApplicationContext是ClassPathXmlApplicationContext，res就是ClassPathResource实例
    */
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext();
        Resource resource = context.getResource("AAA.txt");
        System.out.println(resource.getFilename());
    }

    @Test
    public void demo(){
        ApplicationContext context = new FileSystemXmlApplicationContext();
        Resource resource = context.getResource("AAA.txt");
        System.out.println(resource.getFilename());
    }
}
